<template>
  <div class="listtree">
    <div class="wrap clearfix">
      <!-- <div>{{ arr }}</div> -->
      <!-- <div class="show">
        <ul>
          <li v-for="(item, index) in arr" :key="index">
            <span v-for="(item2, index2) in item.children" :key="index2">
              {{ item2.name }}
            </span>
          </li>
        </ul>
      </div> -->
      <div class="list">
        <ul class="relt">
          <li class="tree" v-for="(item, index) in arr" :key="index">
            {{ item.name }}
            <ul class="listchild">
              <li
                class="second"
                v-for="(item1, index1) in item.children"
                :key="index1"
              >
                <div>{{ item1.name }}&nbsp; ></div>

                <ul class="thirdchild clearfix">
                  <li
                    v-for="(item2, index2) in item1.children"
                    :key="index2"
                    @click="clicks(item2.id)"
                  >
                    {{ item2.name }}
                  </li>
                </ul>
              </li>
            </ul>
          </li>
        </ul>
      </div>

      <div class="index">
        <index_slideshow_slot></index_slideshow_slot>
      </div>
      <div class="pic">
        <ul>
          <li><img src="../../static/img/list1.png" alt="" srcset="" /></li>
          <li><img src="../../static/img/list2.png" alt="" srcset="" /></li>
          <li><img src="../../static/img/list3.png" alt="" srcset="" /></li>
          <li><img src="../../static/img/list4.png" alt="" srcset="" /></li>
          <li><img src="../../static/img/list5.png" alt="" srcset="" /></li>
          <li><img src="../../static/img/list6.png" alt="" srcset="" /></li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import index_slideshow_slot from "./index-slideshow-slot";
export default {
  components: { index_slideshow_slot },
  data() {
    return {
      isshowlist: false,
      arr: [],
      first: [],
      second: [],
      third: [],
      aaa: "",
    };
  },
  methods: {
    href(val) {
    },
    deepCopy(obj) {
      var objClone = Array.isArray(obj) ? [] : {};
      //进行深拷贝的不能为空，并且是对象或者是
      if (obj && typeof obj === "object") {
        for (let key in obj) {
          if (obj.hasOwnProperty(key)) {
            if (obj[key] && typeof obj[key] === "object") {
              objClone[key] = this.deepCopy(obj[key]);
            } else {
              objClone[key] = obj[key];
            }
          }
        }
      }
      return objClone;
    },
    clicks(Id) {
      this.$router.push({ path: "/product", query: { id: Id } });
    },

    showshop(index) {
      this.isshowlist = true;
      this.first = [];
      for (let i = 0; i < this.arr[index].children.length; i++) {
        this.first.push(this.arr[index].children[i]);
      }
    },
    isshowshop() {
      this.isshowlist = false;
    },
  },
  mounted() {
    this.$axios.post("/CommodityType/listTree").then((res) => {
      this.arr = this.deepCopy(res.data.data);
    });
  },
};
</script>
<style scoped>
.list {
  float: left;
  width: 190px;
  height: 470px;
  background-color: #fff;
}
.index {
  margin-left: 10px;
  float: left;
}
.relt {
  position: relative;
  padding: 20px 0;
}
.abso {
  z-index: 7;
  position: absolute;
  right: -500px;
}
.tree {
  font-size: 14px;
  color: #333;
  padding-left: 18px;
  height: 25px;
  line-height: 25px;
}
.tree:hover {
  background-color: #d9d9d9;
}
.tree:hover .listchild {
  display: block;
}
.second {
  height: 29px;
  line-height: 29px;
}
.second > div {
  width: 70px;
  text-align: right;
  display: inline-block;
  height: 19px;
  font-size: 12px;
  vertical-align: top;
  font-weight: 700;
}
.listchild {
  padding-top: 10px;
  display: none;
  width: 998px;
  position: absolute;
  left: 190px;
  background-color: #fff;
  border: 1px solid #f7f7f7;
  min-height: 470px;
  top: 0;
  z-index: 11;
  box-sizing: border-box;
}
.thirdchild {
  display: inline-block;
}

.thirdchild li {
  float: left;
  margin: 7px 0 5px 0;
  padding: 0 7px;
  height: 16px;
  line-height: 16px;
  font-size: 12px;
}
.thirdchild li:hover {
  color: #f10215;
}

.list li:hover {
  cursor: pointer;
}
.showlist {
  position: absolute;
  width: 998px;
  min-height: 468px;
  z-index: 10;
  background-color: #fff;
  border: 1px solid #f7f7f7;
  top: 0;
  left: 190px;
}
.pic img {
  width: 190px;
  height: 150px;
}
.pic ul li {
  float: left;
  margin-left: 10px;
  margin-top: 6px;
}
.pic ul li:nth-child(1),
.pic ul li:nth-child(2) {
  margin-top: 0;
}
</style>